package com.pinapel.aixml.ui;

import java.awt.BorderLayout;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;

import com.pinapel.aixml.tools.i18n.I18n;
import com.pinapel.aixml.tools.log.LogMessage;
import com.pinapel.aixml.tools.log.Logger;


public class LogUI extends JPanel implements Observer{
	
    /**
	 * 
	 */
	private static final long serialVersionUID = 201204131035L;
	private JScrollPane jScrollLogText = new JScrollPane();
    private LogColorPane jLogText = new LogColorPane();
//    private JLabel jName = new JLabel();
    
    public LogUI(){
    	
    	this.setLayout(new BorderLayout());
    	
//    	jName.setText(I18n.getString(I18n.UI006_LOG));
    	jScrollLogText.setViewportView(jLogText);
    	// No es editable
    	jLogText.setEditable(false);
    	
//    	this.add(jName, BorderLayout.NORTH);
    	this.add(jScrollLogText, BorderLayout.CENTER); 

    	Logger.addObserver(this);
    }
    

	@Override
	/**
	 * @params log Un Objeto de la clase LOG
	 * @params arg1 parametros adicionales. NO SE UTILIZA
	 * 
	 */
	public void update(Observable log, Object arg1) {
		List<LogMessage> lista = Logger.getUnreadMessages();
		
		for(LogMessage msg : lista){
			jLogText.append(msg);
		}
		
	}
}
